#include "Timer.h"
#include <windows.h>

class MyStopwatch : public Stopwatch
{
	LARGE_INTEGER last_start;
	long long total;

public:
	MyStopwatch()
	{ reset(); }

	void reset()
	{ total = 0; }

	void start()
	{ QueryPerformanceCounter(&last_start); }

	void stop()
	{
		LARGE_INTEGER now;
		QueryPerformanceCounter(&now);
		total += now.QuadPart - last_start.QuadPart;
	}

	double getElapsed()
	{
		LARGE_INTEGER freq;
		QueryPerformanceFrequency(&freq);
		return total / (double) freq.QuadPart;
	}
};

Stopwatch * createStopwatch()
{
	return new MyStopwatch();
}